package com.neusoft.demo6;

/**
 * private表示私有的：只有当前类可以访问私有的属性，其它类不能访问
 */
public class Person {
    private int pid;
    private String name;
    private int age;
    private String address;

    //创建一个构造方法

    public Person() {

    }

    public Person(int pid, String name) {
        this.pid = pid;
        this.name = name;
    }

    public Person(int pid, String name, int age) {
        this.pid = pid;
        this.name = name;
        this.age = age;
    }

    public Person(int pid, String name, int age, String address) {
        this.pid = pid;
        this.name = name;
        this.age = age;
        this.address = address;
    }

    //获取属性值
    public int getPid() {
        return pid;
    }

    public void setPid(int pid) {
        //this表示当前Person对象自身
        this.pid = pid; //将用户输入的pid给当前Person对象中的pid设置一个值
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public int add(int a,int b){
        return a+b;
    }

    public String add(int a,String b){
        return a+b;
    }

    public static void main(String[] args) {
        Person person3 = new Person();
        String name = person3.add(10,"fender");
        System.out.println(name);

        Person person = new Person(100, "fender", 18, "neu");
        System.out.println(person.getName());
        Person person1 = new Person(101, "gibson", 19, "neu");
        System.out.println(person1.getName());
        Person person2 = new Person(100, "fender");
        person2.setAddress("neu");
        System.out.println(person2.getAddress());
    }

}
